Repository navigation
refactor: share file handling and the REST contract through pivotkit-node - #736
Merged
Merged
Conversation
…node pivotkit-server imported pivotkit-cli/files and pivotkit-cli/rest in 21 modules, so the server depended on its own command line. The shared code moves into a new internal package, pivotkit-node, which both depend on. pivotkit-cli/files and pivotkit-cli/rest re-export the same names, so the published entries stay as they are. - safe-files.js, files.js (readTable) and rest-contract.js move as they are; CliError, asCliError, printable and shortName move from errors.js, RemoteError stays in the CLI. - asCliError's kind mapping for pivotkit-core errors is its own function, so the moved function is under the growth limit. - The file handling's unit and junction tests move with it; CI runs pivotkit-node's tests on Windows and macOS too. - Package lists (workspaces, pack check, release and docs workflows, Dockerfile, RELEASING, README, SECURITY, docs) name the new package. pivotkit-server keeps pivotkit-cli as a dependency only for the `pivotkit-server cli` command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… named - ESLint refuses an import of pivotkit-cli in pivotkit-server, and of pivotkit-cli, pivotkit-server or pivotkit-mcp in pivotkit-node. - RELEASING counts nine packages and says pivotkit-node needs its one-time setup first and moves with cli and server on a minor. - cli.md names the REST service and the MCP server as the users of the file handling; the package counts name the public packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: pivotkit-server no longer imports pivotkit-cli. The shared file handling and REST contract live in a new internal package,
pivotkit-node. Behaviour and published exports stay the same.Why
pivotkit-server imported
pivotkit-cli/filesandpivotkit-cli/rest27 times in 21 modules. A server should not depend on its command line.Where the shared code goes
A new small workspace package,
pivotkit-node, which pivotkit-cli and pivotkit-server both depend on. The CLI stays a leaf. This is the common npm-workspaces answer when two published packages share code without a bundler. The alternatives do not fit:pivotkit-core: browser-safe,fflateonly. The code needsnode:fs,node:net, pivotkit-xlsx and pivotkit-report (a cycle).pivotkit-report: runs in the browser and has no xlsx dependency.pivotkit-server: the CLI would then depend on the server.What changes
safe-files.js,files.js(readTable) andrest-contract.jsmove topackages/pivotkit-nodeunchanged.CliError,asCliError,printableandshortNamemove from the CLI'serrors.js.RemoteErrorstays in the CLI.asCliError's mapping of pivotkit-core errors is its own small function. The logic is the same, and the moved test covers it.pivotkit-cli/filesandpivotkit-cli/restre-export the same names and bindings, soinstanceof CliErrorholds across both. A test checks the identity.pivotkit-server cli, which loads it withimport().Release
pivotkit-nodeis a new npm name. It needs the one-time setup in RELEASING.md before pivotkit-cli or pivotkit-server is released. A minor of it moves cli and server in the same round. RELEASING.md says both.Growth
Gone:
asCliErrorcomplexity (27) and the unused exportPRINT_LENGTH. The baseline is lowered with--update.Checks
npm run lint,npm run types(with the new consumer type test),npm testin every workspace andtests/*.test.js,npm run growthandpack:checkfor pivotkit-node and pivotkit-cli all pass.Object.keyssnapshot).sheet-views,source-data) pass in chromium.Places checked: README (packages, changelogs), AGENTS.md, the package AGENTS.md files, RELEASING.md, SECURITY.md, docs (versioning, features, faq, embed, cli, rest, mcp), the release, docs and CI workflows, the Dockerfile, eslint config, changelogs of cli, server and node.
🤖 Generated with Claude Code